package com.zige.zige.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;

import com.zige.zige.R;

/**
 * Created by Fei on 2015/12/5.
 */
public class LoadingDialog extends AlertDialog {
    ImageView img_loading;

    public LoadingDialog(Context context) {
        this(context, R.style.theme_dialog_loading);
    }


    public LoadingDialog(Context context, int theme) {
        super(context, theme);
    }

    public LoadingDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        setCanceledOnTouchOutside(false);
        setCancelable(true);
        img_loading = (ImageView)findViewById(R.id.img_loading);
        startAnimation();


    }

    private void startAnimation(){
        img_loading.setBackgroundResource(R.drawable.being_loaded);
        AnimationDrawable animation = (AnimationDrawable) img_loading.getBackground();
        animation.start();
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        startAnimation();

    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onStop() {
        super.onStop();


    }




}
